package cn.itcast.jd.task;

import cn.itcast.jd.service.NewService;
import cn.itcast.jd.util.HttpUtils;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;


/**
 * Created by Administrator on 2019/8/9.
 */
@Component
public class NewTask {

    @Autowired
    private HttpUtils httpUtils;

    @Autowired
    private NewService newService;


    //当下在任务完成后，间隔多长时间进行下一次任务。
    @Scheduled(fixedDelay = 10*1000)
    public void NewTask()throws Exception{

        String url="https://www.51job.com";
        String html=httpUtils.doGetHtml(url);

        this.parse(html);

        System.out.println(html);
    }

    private void parse(String html) {

        Document doc= Jsoup.parse(html);

//        Elements spuEles=doc.select("ul.list_3>li>a");
//
//        for (Element spuEle:spuEles){
//           String title= spuEle.attr("title").toString();
//
//            System.out.println(title);
//        }






    }
}
